package com.lab.service.impl;

import com.lab.dao.DeviceDao;
import com.lab.pojo.Device;
import com.lab.service.DeviceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("deviceService")
public class DeviceServiceImp implements DeviceService {
    @Resource
    DeviceDao deviceDao;
    public List<Device> allDevices() {
        return deviceDao.allDevices();
    }

    public void saveDevice(Device device) {
        if (device.getDid()!=null){
            //修改
            deviceDao.updateDevice(device);
        }else {
            //增加
            deviceDao.addDevice(device);
        }
    }

    public void deleteDevice(Long[] did) {
        deviceDao.deleteDevice(did);
    }

    public Device findDeviceById(Long did) {
        return deviceDao.findDeviceById(did);
    }

    public List<Device> findDevicesScrap() {
        return deviceDao.findDevicesScrap();
    }

    public List<Device> findDevicesRepair() {
        return deviceDao.findDevicesRepair();
    }

    public List<Device> findDevicesUsed() {
        return deviceDao.findDevicesUsed();
    }
}
